package com.example.base.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.base.system.domain.SysLog;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author X.I.O
 * @since 2024-02-24
 */
public interface SysLogMapper extends BaseMapper<SysLog> {

    @Select(" SELECT DATE(log_createdate) AS date, COUNT(*) AS total FROM sys_log " +
            " WHERE log_createdate >= CURDATE() - INTERVAL 15 DAY GROUP BY DATE(log_createdate) ORDER BY date")
    public List<Map<String,Object>> getPast15DaysTotal();

    @Select("SELECT DATE(log_createdate) AS date, COUNT(*) AS total \n" +
            "            FROM sys_log \n" +
            "            WHERE log_createdate >= #{startDate} AND log_createdate <=#{endDate} \n" +
            "            GROUP BY DATE(log_createdate) \n" +
            "            ORDER BY date")
    public List<Map<String,Integer>> getPastDaysTotal(@Param("startDate")String startDate,@Param("endDate")String endDate);
}
